import pandas as pd
import numpy as np
query=pd.read_json('./small_dev-1.json')

docs=query['docs']
c=[]
d=[]
p=[]
q=[]
for i in range(len(query)):
    for j in range(len(docs[i])):
        c.append(docs[i][j]['content'])
        d.append(docs[i][j]['didx'])
        p.append(query['qidx'])
        q.append(query['q'])
df1=pd.DataFrame({'qidx_':p,'q':q,'content':c,'didx':d})
df1['label']=[0 for i in range(len(df1))]


label=query['labels']
list(label[0].items())
labels=[]
for i in range(len(label)):
    for j in range(len(list(label[i].items()))):
        labels.append(list(label[i].items())[j])


for i in range(len(df1)):
    for j in range(len(labels)):
        if df1.loc[i,'didx'] == labels[j][0]:
            df1.loc[i,'label'] = labels[j][1]
            
df1.to_csv('predata_q.csv',encoding='utf-8')